<div id="tb<?php echo $uniqid;?>" style="padding:5px">
    <table cellspacing="0" cellpadding="0">
        <tbody>
        <tr>
<!--            <td><a href="javascript:void(0);" onclick="sysfaqManageAdd();" class="l-btn l-btn-small l-btn-plain"><span-->
<!--                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-tianjia1"></i><span class="l-btn-text">增加</span></span></a></td>-->
<!--            <td>-->
<!--                <div class="datagrid-btn-separator"></div>-->
<!--&lt;!&ndash;            </td>&ndash;&gt;-->
<!--            <td><a href="javascript:void(0);" onclick="sysfaqManageEdit();" class="l-btn l-btn-small l-btn-plain"><span-->
<!--                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-bianji"></i><span class="l-btn-text">编辑</span></span></a></td>-->
<!--            <td>-->
<!--                <div class="datagrid-btn-separator"></div>-->
<!--            </td>-->
<!--            <td><a href="javascript:void(0);" onclick="sysfaqManageDelete();" class="l-btn l-btn-small l-btn-plain"><span-->
<!--                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shanchu"></i><span class="l-btn-text">删除</span></span></a></td>-->
<!--            <td>-->
<!--                <div class="datagrid-btn-separator"></div>-->
<!--            </td>-->
            <td><a href="javascript:void(0);" onclick="sysfaqManageReload();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-shuaxin"></i><span class="l-btn-text">重载</span></span></a></td>
            <td>&nbsp;&nbsp;<input id="sysfaqManageKeywords" style="width:300px" type="text" placeholder="请输入常见问题ID或者标题"
                                  class="easyui-input textbox"></td>
            <td><a href="javascript:void(0);" onclick="sysfaqManageSearch();" class="l-btn l-btn-small l-btn-plain"><span
                    class="l-btn-left l-btn-icon-left"><i class="iconfont icon-sousuo"></i><span class="l-btn-text">查询</span></span></a></td>
        </tr>
        </tbody>
    </table>
</div>
<div class="con"  style="-moz-user-select:none;">
    <table id="sysfaqManage"></table>
</div>
<div id="sysfaqManageDlg" class="easyui-dialog" style="width:1040px; height:640px;" title="信息框" closed="true"></div>
<script>
    var sysfaqManageAdd = function () {
        $("#sysfaqManageDlg").dialog({
            title: '新增常见问题',
            closed: false,
            width: 1040,
            height: 680,
            cache: false,
            href: '/admin/feedback/add',
            modal: true,
            buttons: [{
                text: '保存',
                id: 'sysfaqEditsubmit',
                iconCls: 'icon-ok',
            }, {
                text: '关闭',
                iconCls: 'icon-no',
                handler: function () {
                    $("#sysfaqManageDlg").dialog('close');
                }
            }]
        });
    };
    var sysfaqManageEdit = function (id) {
        if (id) {
            $("#sysfaqManageDlg").dialog({
                title: '编辑信息',
                closed: false,
                width: 1040,
                height: 680,
                cache: false,
                href: '/admin/feedback/edit?id=' + id,
                modal: true,
                buttons: [{
                    text: '保存',
                    id: 'sysfaqEditsubmit',
                    iconCls: 'icon-ok',
                }, {
                    text: '关闭',
                    iconCls: 'icon-no',
                    handler: function () {
                        $("#sysfaqManageDlg").dialog('close');
                    }
                }]
            });
        } else {
            $.messager.alert('提示', '请先选择要编辑的行！', 'warning');
        }
    };
    var sysfaqManageDelete = function () {
        var row = $('#sysfaqManage').datagrid('getSelected');
        if (row) {
            $.messager.confirm('提示', '确定删除吗？', function (r) {
                if (r) {
                    $.messager.progress();
                    $.post('/admin/feedback/delete', {id: row.id}, function (data) {
                        $.messager.progress('close');
                        if (data.ret == 0) {
                            $.messager.show({
                                title: '提示',
                                msg: data.msg,
                                timeout: 3000,
                                showType: 'slide'
                            });
                            sysfaqManageload();
                        } else {
                            $.messager.alert('提示', data.msg, 'warning');
                        }
                    }, 'json');
                }
            });
        } else {
            $.messager.alert('提示', '请先选择要删除的行！', 'warning');
        }
    };
    var sysfaqManageReload = function () {
        $("#sysfaqManage").datagrid('reload');
    };
    var sysfaqManageload = function () {
        $('#sysfaqManageKeywords').val('');
        $("#sysfaqManage").datagrid('load', {keywords:''});
    };
    var sysfaqManageSearch = function () {
        var height = $(window).height() - $(".top").height() - 46;
        var width = $(window).width() - $(".leftmenu").width() - 8;
        $("#sysfaqManage").datagrid({
            title: '常见问题管理',
            width: width,
            height: height,//高度
            singleSelect: true,//如果为true，则只允许选择一行
            striped: true,//是否显示斑马线效果。
            rownumbers: false,//如果为true，则显示一个行号列。
            pagination: true,//是否显示分页
            pageSize: 10,
            pageList: [10, 15, 20, 25],
            method: 'post',
            sortName: 'created_at',
            sortOrder: 'desc',
            idField: 'id',
            treeField: 'title',
            url: '/admin/feedback/index',
            queryParams: {keywords: $('#sysfaqManageKeywords').val()},
            fitColumns: true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
            nowrap: true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
            selectOnCheck: false,
            checkOnSelect: true,
            toolbar: '#tb<?php echo $uniqid;?>',
            columns: [[
                {field: 'id', title: 'ID', width: fixWidth(3)},
                {field: 'content', title: '内容', width: fixWidth(30)},
                {field: 'phone', title: '联系方式', width: fixWidth(20)},
                {field: 'username', title: '用户名', width: fixWidth(20)},
                {
                    field: 'title', title: '图片', width: '32%', formatter: function (value, rowData, rowIndex) {
                        return '<div style="display: flex;align-items: center;">' +
                            '<img src="' + rowData.image + '?imageView2/1/w/60/h/60" style="height:60px;width:60px;border-radius: 5px;border:#dfdfdf 1px solid;">';
                    }
                },
                // {field: 'status', title: '状态', width: fixWidth(20), formatter(value, rowData, rowIndex){
                //         return value===1 ? '显示' : '隐藏';
                //     }},

                {field: 'created_at', title: '创建时间', width: fixWidth(20)},
                {field: 'action', title: '操作', width: fixWidth(13), formatter: function (value, rowData, rowIndex) {
                        return '<a href="javascript:;" class="l-btn l-btn-small" onclick="sysfaqManageEdit(' + rowData.id + ')" ><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">回复</span><span class="l-btn-icon icon-ok">&nbsp;</span></span></a>&nbsp;&nbsp;'
                             }
                },
            ]],
            onDblClickRow: function (index, field) {
                sysfaqManageEdit();
            }
        });
    };
    onDatagridResize("#sysfaqManage");
    sysfaqManageSearch();
</script>
